/**
 * Copyright � 2012 GestureSoft. ALL RIGHTS RESERVED.
 * This file contains proprietary and GestureSoft CONFIDENTIAL Information.
 * Use, disclosure or reproduction is prohibited.
 * 
 * @fileName DBConfig.as
 * @creationDate Aug 8, 2012
 * @author 
 * @version 1.0
 */
package com.gesturesoft.imultimax.model.dbmanager
{
	[Bindable]
	public class DBConfig
	{
		
		
		
		//START:Database Version 1 details
		
		//public static const DB_VERSION_1_13:String = "DROP TABLE IF EXISTS dbversion";
		
		/*private static const DROP_TABLE1:String = "DROP TABLE IF EXISTS dbversion";
		
		private static const DB_VERSION_1_0:String = "CREATE TABLE IF NOT EXISTS dbversion (" +
			"version STRING, executed STRING)";
		
		private static const DB_VERSION_1_1:String = "INSERT INTO dbversion (version) " + 
			"VALUES('DB_VERSION_0')";
		
		private static const DB_VERSION_1_2:String = "CREATE TABLE IF NOT EXISTS companies (" +
			"version STRING, " + 
			"appname STRING, " +
			"server STRING, " +
			"configFile STRING, " +
			"is_enable STRING, " +
			"startup STRING, " +
			"asset_version STRING, " +
			"style_version STRING, " +
			"currency STRING" +
			")";
		
		private static const DB_VERSION_1_3:String = "CREATE TABLE IF NOT EXISTS style_main (" +
			"asset_version STRING, " + 
			"style_version STRING, " +
			"company STRING )";
		
		private static const DB_VERSION_1_4:String ="CREATE TABLE IF NOT EXISTS assets (" +
			"name STRING, " + 
			"type STRING, " +
			"value STRING, "+
			"company STRING )";
		
		private static const DB_VERSION_1_5:String = "CREATE TABLE IF NOT EXISTS styles (" +
			"class_name STRING, " + 
			"property STRING, " +
			"value STRING, "+
			"company STRING )";
		
		private static const DB_VERSION_1_6:String = "CREATE TABLE IF NOT EXISTS currencies (" +
			"label STRING, " + 
			"country STRING)";
		
		private static const DB_VERSION_1_7:String = "CREATE TABLE IF NOT EXISTS user (" +
			"pin_number STRING," +
			" email STRING," +
			" phone_number STRING," +
			" activation_code STRING," +
			" status STRING," +
			" attempt STRING," +
			" locked STRING)";
		
		private static const DB_VERSION_1_8:String = "CREATE TABLE IF NOT EXISTS beforelist (" +
			"name STRING, contact STRING, amount STRING, type STRING," +
			" date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		private static const DB_VERSION_1_9:String = "CREATE TABLE IF NOT EXISTS savedforlater (" +
			"name STRING, contact STRING, amount STRING, status STRING, type STRING," +
			" date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		private static const DB_VERSION_1_10:String = "CREATE TABLE IF NOT EXISTS locationtable (" +
			"longitude STRING, latitude STRING, distance STRING," +
			" date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		private static const DB_VERSION_1_11:String = "CREATE TABLE IF NOT EXISTS networkinfotable (" +
			"interfaceName STRING, mTU STRING, display_Name_Interface STRING, active STRING," +
			" hardware_Address STRING, address STRING, broadcast_address STRING, ipversion STRING, prefixlength STRING)";
		
		private static const DB_VERSION_1_12:String = "CREATE TABLE IF NOT EXISTS androidnetworkinfotable (" +
			"interfaceName STRING, mTU STRING, display_Name_Interface STRING, active STRING," +
			" hardware_Address STRING, address STRING, broadcast_address STRING, ipversion STRING, prefixlength STRING)";
		
		//private static const DB_VERSION_1_13:String = "DROP TABLE IF EXISTS activities";
		
		private static const DB_VERSION_1_14:String = "CREATE TABLE IF NOT EXISTS activities (" +
			"activity STRING," +
			"date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";*/
		
		//END:DB version 1 details
		
		//START:DB version 2 details
		
		/*private static const DB_VERSION_2_0:String = "ALTER TABLE activities ADD COLUMN result STRING";
		
		private static const DB_VERSION_2_1:String = "ALTER TABLE activities ADD COLUMN action STRING";
		
		private static const DB_VERSION_2_2:String = "UPDATE dbversion SET version='DB_VERSION_1'";*/
		
		//END:DB version 2 details
		
		//START:DB version 3 details
		/*private static const DB_VERSION_3_0:String = "ALTER TABLE user ADD COLUMN usr_activation_rqst_time STRING";
		
		private static const DB_VERSION_3_1:String = "UPDATE dbversion SET version='DB_VERSION_2'";*/
		//END:DB version 3 details")
		
		// Queries for db version 1
		/*private static const DB_VERSION_0:Array = [DROP_TABLE1,DB_VERSION_1_0, DB_VERSION_1_1, 
			DB_VERSION_1_2, DB_VERSION_1_3,
			DB_VERSION_1_4, DB_VERSION_1_5,
			DB_VERSION_1_6, DB_VERSION_1_7,
			DB_VERSION_1_8, DB_VERSION_1_9,
			DB_VERSION_1_10, DB_VERSION_1_11,
			DB_VERSION_1_12,
			DB_VERSION_1_14]; */
		
		// Queries for db version 2
		/*private static const DB_VERSION_1:Array = [DROP_TABLE1, DB_VERSION_1_0, DB_VERSION_1_1, 
			DB_VERSION_1_2, DB_VERSION_1_3,
			DB_VERSION_1_4, DB_VERSION_1_5,
			DB_VERSION_1_6, DB_VERSION_1_7,
			DB_VERSION_1_8, DB_VERSION_1_9,
			DB_VERSION_1_10, DB_VERSION_1_11,
			DB_VERSION_1_12, DB_VERSION_1_14,
			DB_VERSION_2_0, DB_VERSION_2_1,
			DB_VERSION_2_2];*/
		
		// Queries for db version 3
		//private static const DB_VERSION_2:Array = [DB_VERSION_3_0, DB_VERSION_3_1];
		
		//public static const DB_VERSIONS:Array = [DB_VERSION_0, DB_VERSION_1 , DB_VERSION_2]; // All versions of database
		
		////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		//DATABASE_VERSION
		private static const DB_VERSION_1_0:String = "CREATE TABLE IF NOT EXISTS IM_DATABASE_VERSION (" +
			"v_version STRING, v_executed STRING)";
		
		private static const DB_VERSION_1_1:String = "INSERT INTO IM_DATABASE_VERSION (v_version) " + 
			"VALUES('DB_VERSION_0')";
		
		//COMPANIES
		private static const DB_VERSION_1_2:String = "CREATE TABLE IF NOT EXISTS IM_COMPANIES (" +
			"cmp_version STRING, " + 
			"cmp_company STRING, " +
			"cmp_server STRING, " +
			"cmp_configFile STRING, " +
			"cmp_is_enable STRING, " +
			"cmp_startup STRING, " +
			"cmp_asset_version STRING, " +
			"cmp_style_version STRING, " +
			"cmp_currency STRING" +
			")";
		
		//STYLE_MAIN
		private static const DB_VERSION_1_3:String = "CREATE TABLE IF NOT EXISTS IM_STYLE_MAIN (" +
			"sm_asset_version STRING, " + 
			"sm_style_version STRING, " +
			"sm_company STRING )";
		
		//ASSETS
		private static const DB_VERSION_1_4:String ="CREATE TABLE IF NOT EXISTS IM_ASSETS (" +
			"as_name STRING, " + 
			"as_type STRING, " +
			"as_value STRING, "+
			"as_company STRING )";
		
		//STYLES
		private static const DB_VERSION_1_5:String = "CREATE TABLE IF NOT EXISTS IM_STYLES (" +
			"st_class_name STRING, " + 
			"st_property STRING, " +
			"st_value STRING, "+
			"st_company STRING )";
		
		//CURRENCIES
		private static const DB_VERSION_1_6:String = "CREATE TABLE IF NOT EXISTS IM_CURRENCIES (" +
			"cur_label STRING, " + 
			"cur_country STRING)";
		
		//USER
		private static const DB_VERSION_1_7:String = "CREATE TABLE IF NOT EXISTS IM_USER (" +
			" usr_pin_number STRING," +
			" usr_email STRING," +
			" usr_phone_number STRING," +
			" usr_activation_code STRING," +
			" usr_status STRING," +
			" usr_attempt STRING," +
			" usr_locked STRING," +
			" usr_activation_rqst_time STRING)";
		
		//BEFORE_LIST
		private static const DB_VERSION_1_8:String = "CREATE TABLE IF NOT EXISTS IM_BEFORE_LIST (" +
			"bl_name STRING, bl_contact STRING, bl_amount STRING, bl_type STRING," +
			" bl_date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		//SAVED_FOR_LATER
		private static const DB_VERSION_1_9:String = "CREATE TABLE IF NOT EXISTS IM_SAVED_FOR_LATER (" +
			"sfl_name STRING, sfl_contact STRING, sfl_amount STRING, sfl_status STRING, sfl_type STRING," +
			" sfl_date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		//LOCATION
		private static const DB_VERSION_1_10:String = "CREATE TABLE IF NOT EXISTS IM_LOCATION (" +
			"loc_longitude STRING, loc_latitude STRING, loc_distance STRING," +
			"loc_date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		//IPHONE_NET_INFO
		private static const DB_VERSION_1_11:String = "CREATE TABLE IF NOT EXISTS IM_IPHONE_NET_INFO (" +
			"ini_interfaceName STRING, ini_mTU STRING, ini_display_Name_Interface STRING, ini_active STRING," +
			"ini_hardware_Address STRING, ini_address STRING, ini_broadcast_address STRING, ini_ipversion STRING, ini_prefixlength STRING)";
		
		//ANDROID_NETWORK_INFO
		private static const DB_VERSION_1_12:String = "CREATE TABLE IF NOT EXISTS IM_ANDROID_NETWORK_INFO (" +
			"ani_interfaceName STRING, ani_mTU STRING, ani_display_Name_Interface STRING, ani_active STRING," +
			"ani_hardware_Address STRING, ani_address STRING, ani_broadcast_address STRING, ani_ipversion STRING, ani_prefixlength STRING)";
		
		//ACTIVITIES
		private static const DB_VERSION_1_13:String = "CREATE TABLE IF NOT EXISTS IM_ACTIVITIES (" +
			"act_activity STRING," +
			"act_date TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime'))," +
			"act_action STRING, act_result STRING)";
		

		//Queries for db version 2
		
		//THEME_LIST
		/*private static const DB_VERSION_2_0:String = "CREATE TABLE IF NOT EXISTS THEMES (" +
			" primary_color STRING," +
			" secondary_color STRING," +
			" label_color STRING," +
			" th_secondary_label_color STRING,"+
			" th_background STRING,"+
			" active STRING," +
			" creator STRING," +
			" creation_time TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')))";
		
		//ACTIVE_THEME
		private static const DB_VERSION_2_1:String = "CREATE TABLE IF NOT EXISTS ACTIVE_THEME (" +
			" primary_color STRING," +
			" secondary_color STRING," +
			" label_color STRING," +
			" at_secondary_label_color STRING," +
			" at_background STRING)";*/
		
		//THEMES
		private static const DB_VERSION_2_0:String = "CREATE TABLE IF NOT EXISTS IM_THEMES(" +
			"th_id INTEGER PRIMARY KEY AUTOINCREMENT," +
			"th_name STRING," +
			"th_active STRING," +
			"th_creator STRING," +
			"creation_time TEXT DEFAULT (strftime('%d-%m-%Y %H:%M:%S','now', 'localtime')) )";
		
		//THEME_DETAILS
		private static const DB_VERSION_2_1:String = "CREATE TABLE IF NOT EXISTS IM_THEME_DETAILS(" +
			"property_name STRING," +
			"value STRING," +
			"gradient1 STRING," +
			"gradient2 STRING," +
			"stroke STRING,"+
			"text_color STRING," +
			"td_id INTEGER,"+
			"FOREIGN KEY (td_id) REFERENCES IM_THEMES(th_id) )";
		
		//ACTIVE_THEME
		/*private static const DB_VERSION_2_2:String = "CREATE TABLE IF NOT EXISTS IM_ACTIVE_THEME(" +
			"property_name STRING," +
			"values STRING," +
			"gradient1 STRING," +
			"gradient2 STRING," +
			"text_color STRING," +
			"FOREIGN KEY (td_id) REFERENCES IM_THEMES(id) )";*/
		
		private static const DB_VERSION_2_3:String = "UPDATE IM_DATABASE_VERSION SET v_version='DB_VERSION_1'";
		
		//THEME_VERSION
		private static const DB_VERSION_2_4:String = "CREATE TABLE IF NOT EXISTS THEME_VERSION (" +
			" theme_version STRING)";
		
		//IM_AUTH_SETTINGS
		private static const DB_VERSION_2_5:String = "CREATE TABLE IF NOT EXISTS IM_AUTH_SETTINGS (" +
			" au_property STRING," +
			" au_primary STRING," +
			" au_secondary STRING)";
		
		//AUTH METHOD
		private static const DB_VERSION_2_6:String = "ALTER TABLE IM_USER ADD COLUMN usr_method STRING";
		
		
		private static const DB_VERSION_2_7:String = "ALTER TABLE IM_ASSETS ADD COLUMN as_active_table_propery STRING";
		
		private static const DB_VERSION_2_8:String = "ALTER TABLE IM_STYLES ADD COLUMN st_active_table_propery STRING";
		
		//Add subproperty to IM_STYLES ie: sub property is gradient1 for property secondary color
		private static const DB_VERSION_2_9:String = "ALTER TABLE IM_STYLES ADD COLUMN st_active_table_sub_propery STRING";
		
		private static const DB_VERSION_2_10:String = "CREATE TABLE IF NOT EXISTS IM_API_SETTINGS (" +
			" api_name STRING," +
			" email_required STRING,"+
			" api_required STRING)";
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		/////////////////////////////////START:DB Version 3///////////////////////////////////////////
		private static const DB_VERSION_3_0:String = "DROP TABLE IF EXISTS IM_LOCATION";
		
		private static const DB_VERSION_3_1:String = "UPDATE IM_DATABASE_VERSION SET v_version='DB_VERSION_2'";
		
		private static const DB_VERSION_3_2:String = "CREATE TABLE IF NOT EXISTS IM_GPS_LOCATION(" +
			"id INTEGER PRIMARY KEY AUTOINCREMENT, min_lattitude REAL, max_lattitude REAL, min_longitude REAL, max_longitude REAL)";
		
		/////////////////////////////////END:DB Version 3/////////////////////////////////////////////////////
		
		/////////////////////////////////START:DB Version 4///////////////////////////////////////////
		private static const DB_VERSION_4_0:String = "UPDATE IM_DATABASE_VERSION SET v_version='DB_VERSION_3'";
		
		private static const DB_VERSION_4_1:String = "CREATE TABLE IF NOT EXISTS IM_BANKS(" +
			"bank_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"bank_logo STRING,"+
			"bank_name STRING)";
		
		private static const DB_VERSION_4_2:String = "CREATE TABLE IF NOT EXISTS IM_CARD_COLORS("+
			"card_color_id INTEGER PRIMARY KEY AUTOINCREMENT," +
			"card_color_gradient1 STRING,"+
			"card_color_gradient2 STRING)";
		
		/*private static const DB_VERSION_4_3:String = "CREATE TABLE IF NOT EXISTS IM_CARD_SKINS("+
			"card_skin_id INTEGER PRIMARY KEY AUTOINCREMENT," +
			"card_skin_name STRING)";*/
		
		private static const DB_VERSION_4_4:String = "CREATE TABLE IF NOT EXISTS IM_CARD_DETAILS(" +
			"card_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"card_type STRING," +
			"card_number INTEGER," +
			"card_pin INTEGER," +
			"card_name STRING,"+
			"card_expiry_month STRING," +
			"card_expiry_year STRING," +
			"card_currency STRING,"+
			"card_balance INTEGER,"+
			"card_available_balance INTEGER,"+
			"card_bank STRING,"+
			"card_is_favorite INTEGER,"+
			"card_is_sec_choice INTEGER,"+
			"card_color_id INTEGER," +
			"card_skin_name STRING," +
			"FOREIGN KEY (card_color_id) REFERENCES IM_CARD_COLOR(card_color_id))";
		
		private static const DB_VERSION_4_5:String = "INSERT INTO IM_BANKS (bank_name, bank_logo) VALUES('SBI', '')";
			
		
		private static const DB_VERSION_4_6:String = "INSERT INTO IM_BANKS (bank_name, bank_logo) VALUES('ICICI', '')";
			
		
		private static const DB_VERSION_4_7:String = "INSERT INTO IM_BANKS (bank_name, bank_logo) VALUES('MULIMAX', '')";
		
		
		private static const DB_VERSION_4_8:String = "CREATE TABLE IF NOT EXISTS IM_WALLET_CATEGORY("+
			"category_id INTEGER PRIMARY KEY AUTOINCREMENT," +
			"category_name STRING,"+
			"view STRING,"+
			"view_Class STRING)";
		
		//---------------------Color table for card, not used--------------------------//
		private static const DB_VERSION_4_9:String = "CREATE TABLE IF NOT EXISTS IM_CARD_COLOR(" +
			"color_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"for_gradient1 STRING," +
			"for_gradient2 STRING," +
			"back_gradient1 STRING," +
			"back_gradient2 STRING)";
		
		/////////////////////////////////END:DB Version 4///////////////////////////////////////////
		
		/////////////////////////////////START:DB Version 5///////////////////////////////////////////
		
		private static const DB_VERSION_5_0:String = "UPDATE IM_DATABASE_VERSION SET v_version='DB_VERSION_4'";
		
		private static const DB_VERSION_5_1:String = "CREATE TABLE IF NOT EXISTS IM_MAIN_CAT_MASTER(" +
			"cat_master_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"cat_master_name STRING," +
			"cat_master_type STRING)";
		
		private static const DB_VERSION_5_2:String = "CREATE TABLE IF NOT EXISTS IM_SUB_CAT_MASTER(" +
			"sub_cat_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"main_cat_id INTEGER," +
			"sub_cat_name STRING," +
			"FOREIGN KEY (main_cat_id) REFERENCES IM_MAIN_CAT_MASTER(cat_master_id) )";
		
		private static const DB_VERSION_5_3:String = "CREATE TABLE IF NOT EXISTS IM_TEMPLATES_MASTER(" +
			"tmpl_master_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"sub_cat_id INTEGER," +
			"tmpl_sequence INTEGER," +
			"FOREIGN KEY (sub_cat_id) REFERENCES IM_SUB_CAT_MASTER(sub_cat_id) )";
		
		private static const DB_VERSION_5_4:String = "CREATE TABLE IF NOT EXISTS IM_WALLET_MASTER(" +
			"wallet_master_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"sub_cat_id INTEGER," +
			"FOREIGN KEY (sub_cat_id) REFERENCES IM_SUB_CAT_MASTER(sub_cat_id) )";
		
		private static const DB_VERSION_5_5:String = "CREATE TABLE IF NOT EXISTS IM_PAGE(" +
			"page_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"page_width INTEGER," +
			"page_height INTEGER," +
			"page_corner_radius INTEGER," +
			"page_bg_image STRING," +
			"page_logo_image STRING," +
			"page_need_ribon INTEGER," +
			"page_tmpl_master_id INTEGER," +
			"FOREIGN KEY (page_tmpl_master_id) REFERENCES IM_TEMPLATES_MASTER(tmpl_master_id) )";
		
		private static const DB_VERSION_5_6:String = "CREATE TABLE IF NOT EXISTS IM_ELEMENT_MASTER(" +
			"element_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"element_type STRING," +
			"element_change_type STRING," +
			"element_width INTEGER," +
			"element_height INTEGER," +
			"element_left INTEGER," +
			"element_right INTEGER," +
			"element_top INTEGER," +
			"element_bottom INTEGER," +
			"element_horizontal_center INTEGER," +
			"element_vertical_center INTEGER," +
			"element_text STRING," +
			"element_label STRING," +
			"element_font_size INTEGER," +
			"element_font_weight INTEGER," +
			"element_color STRING," +
			"element_text_align STRING," +
			"element_need_format INTEGER," +
			"element_page_id INTEGER," +
			"FOREIGN KEY (element_page_id) REFERENCES IM_PAGE(page_id) )";
		
		private static const DB_VERSION_5_7:String = "CREATE TABLE IF NOT EXISTS IM_WALLET_DATA(" +
			"wallet_data_id  INTEGER PRIMARY KEY AUTOINCREMENT," +
			"wallet_master_id INTEGER," +
			"FOREIGN KEY (wallet_master_id) REFERENCES IM_WALLET_MASTER(wallet_master_id) " +
			"element_id INTEGER," +
			"FOREIGN KEY (element_id) REFERENCES IM_ELEMENT_MASTER(element_id)," +
			"wallet_data_value INTEGER )";
		
		
		/////////////////////////////////END:DB Version 5///////////////////////////////////////////
		
		
		//Query array for db version1
		private static const DB_VERSION_0:Array = [DB_VERSION_1_0, DB_VERSION_1_1, 
			DB_VERSION_1_2, DB_VERSION_1_3,
			DB_VERSION_1_4, DB_VERSION_1_5,
			DB_VERSION_1_6, DB_VERSION_1_7,
			DB_VERSION_1_8, DB_VERSION_1_9,
			DB_VERSION_1_10, DB_VERSION_1_11,
			DB_VERSION_1_12, DB_VERSION_1_13];
			
		////////////////////////////////////
		//Queries for db version2
		private static const DB_VERSION_2:Array = [DB_VERSION_2_0, DB_VERSION_2_1,
												  DB_VERSION_2_3,
												  DB_VERSION_2_4, DB_VERSION_2_5,
												  DB_VERSION_2_6, DB_VERSION_2_7,
												  DB_VERSION_2_8, DB_VERSION_2_9,
												  DB_VERSION_2_10];
		
		//Queries for db version3
		private static const DB_VERSION_3:Array = [DB_VERSION_3_0, DB_VERSION_3_1, DB_VERSION_3_2];
		
		//Queries for db version4
		private static const DB_VERSION_4:Array = [DB_VERSION_4_0, DB_VERSION_4_1, DB_VERSION_4_2, 
			DB_VERSION_4_4, DB_VERSION_4_5, DB_VERSION_4_6, DB_VERSION_4_7, DB_VERSION_4_8];
		
		//Queries for db version5
		private static const DB_VERSION_5:Array = [DB_VERSION_5_0,DB_VERSION_5_1,DB_VERSION_5_2,DB_VERSION_5_3,
			DB_VERSION_5_4,DB_VERSION_5_5,DB_VERSION_5_6,DB_VERSION_5_7];
		
		public static const DB_VERSIONS:Array = [DB_VERSION_0, DB_VERSION_2,   // All versions of database
												DB_VERSION_3, DB_VERSION_4, DB_VERSION_5]; 
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
	}
	
}